<?php
/**
 * @Author: Marte
 * @Date:   2017-08-19 11:02:46
 * @Last Modified by:   Marte
 * @Last Modified time: 2017-08-26 12:27:10
 */
header('Content-Type:text/html;charset=utf-8');
require 'data/config_connect.php';

if(isset($_GET['page']))
{
  $_page=$_GET['page'];
  if(empty($_page)||$_page<=0||!is_numeric($_page))
  {
     $_page=1;
  }
  else
  {
    $_page=intval($_page);//取整
  }
}
else
{
  $_page=1;
}
// 分页效果
$_pagesize=20;//每页有几条
$_pagenum=($_page-1)*$_pagesize;//每页第一个
mysqli_query($_mysql,"SELECT noticeid FROM notice");

$_pagesnum=ceil(mysqli_affected_rows($_mysql)/$_pagesize);//共有几页
//如果$_page>总页数
if($_page>$_pagesnum)
{
  $_page=$_pagesnum;
}



$_sql='select * from notice where status="1" order by noticeid desc limit '.$_pagenum.','.$_pagesize.'';
$_result=$_mysql->query($_sql);

?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <title>公告</title>
    <link rel="stylesheet" type="text/css" href="css/notice.css">
     <script src="js/jquery-3.2.1.min.js"></script>
     <script src="js/send_search_con.js" type="text/javascript" charset="utf-8" ></script>


</head>
<body>
    <div class="header">
        <div class="header_main">
            <div class="header_left">
             <?php

            session_start();

            if(!isset($_GET["action"])||$_GET['action']!='1')
            {
                echo '<span>欢迎您来到墨悦轩！请<a href="dl.php" title="">登录</a>或<a href="zc.php" title="">免费注册</a></span>';
                  // unset($_SESSION['username']);
            }else if($_GET['action']=='1')
            {
                echo '<span>欢迎<a href="person.php">'.$_SESSION['username'].'</a>来到墨悦轩！<a href="data/user/logout.php?exit=1" >退出</a></span>';

            }

            ?>





            </div>
            <div class="header_right">
                <a class="header_right_books" href="allbooks.php" title="">墨轩书城</a>
                <a class="header_right_me" href="mybookrack.php" title="">我的书架</a>
                <a class="header_right_free" href="#" title="">免费小说</a>
                <a class="header_right_month" href="author_register.php" title="">作者专区</a>
                <a class="header_right_last" href="person.php" title="">个人中心</a>
            </div>
        </div>
    </div>

      <!-- search -->
    <div id="search">
        <div class="logo">
                <img src="images/logo1.png" alt="">
        </div>
        <div class="search_main">
            <div class="search_main_box">
                <input class="input" type="text" name="" value="请输入关键字">
            </div>
            <a class="search_main_box_search" href="#" title="">搜&nbsp;索</a>
        <p class="hot_search">热搜： <a href="#" title="">至尊重生</a> <a href="#" title="">透视之眼</a> <a href="#" title="">神医小农名</a>
        </p>
        </div>

        <div class="search_right">

            <div class="search_right_box">

                    <a href="mybookrack.php" title="书架">俺的书架</a>
            </div>
        </div>
    </div>
    <!-- nav -->
    <div class="nav">
        <div class="nav_main" id="bar">
            <div id="navbar">
                <div class="one">

                </div>
                <div class="two">

                </div>
            </div>
            <ul>
                <li><a href="index.php" title="">首页</a></li>
                <li><a href="allbooks.php" title="">全部作品</a></li>
                <li><a href="#" title="">完本</a></li>
                <li><a href="#" title="">排行榜</a></li>
                <li><a href="author_register.php" title="">作者专区</a></li>
                 <li><a href="person.php?change=2" title="">充值</a></li>
            </ul>
        </div>
    </div>

    <!-- 公告导向 -->

    <?php
        if(isset($_GET['noticeid']))
    {
            echo '<p class="notice_nav"><a href="index.php" title="">首页&nbsp;&nbsp;></a><a href="notice.php" title="">咨询中心&nbsp;&nbsp;></a><a href="#" title="">正文</a></p>';
    }
    else{
        echo '<p class="notice_nav"><a href="index.php" title="">首页&nbsp;&nbsp;></a><a href="notice.php" title="">咨询中心&nbsp;&nbsp;></a></p>';
    }
    ?>


    <div class="clear">

    </div>
    <div class="main">

        <?php
                if(!isset($_GET['noticeid']))
                {
                    include 'include/notice_1_inc.php';
                }
                else
                {
                    include 'include/notice_2.inc.php';
                }
        ?>

    <div class="main_right">
            <span class="main_left_title">热门新闻</span>
            <ul>
                <?php
                    $_sql1='select * from notice  where ishot=1 and status="1"';
                    $_result1=$_mysql->query($_sql1);
                      while ($_assoc1=$_result1->fetch_assoc()) {
                                echo '<li>
                    <a href="notice.php?noticeid='.$_assoc1['noticeid'].'" title="">'.$_assoc1['noticetitle'].'</a>

                    </li>';
                        }
                ?>
            </ul>
    </div>
    <div class="clear">

    </div>
    </div>


<?php
        include 'include/zhuce.footer.inc.php';
?>
</body>
</html>